<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<script type="text/javascript" src="scripts/shCore.js"></script>
		<script type="text/javascript" src="scripts/shBrushJava.js"></script>
		<script type="text/javascript" src="scripts/shBrushXml.js"></script>
		
		<link rel="stylesheet" type="text/css" href="css/style.css" />
		<link rel="stylesheet" type="text/css" href="css/shCore.css" />
		<link rel="stylesheet" type="text/css" href="css/shThemeEclipse.css" />
	
		<script type="text/javascript">SyntaxHighlighter.all()</script>
		<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" /> 
	</head>

<body onload="setHeight()">
	<div id="banner">
		<img src="images/banner.png" />
	</div>
	
	<br /><br /><br />
	
	<div id="menu">
	<ul>
		<li><a href="index.php">Home</a></li>
		<li><a href="index.php?page=users">Members</a></li>
		<li><a href="index.php?page=viewthreads&thread=1">Threads</a><li>
	</ul>
	</div>
		
	<?php
		echo '<div id="content" class="clearfix">';
		$login_sidebar = '<div id="email" >
							<center><font size="3" color="#FFFFFF"><br /><b><u>Login</u></b></font></center><br /><br />
					
							<form name="login" method="POST" action="login.php">
								<table border="0">
								<tr><th align="left"><font color="#FFFFFF">Username</font></th><th><input type="text" name="uname" /></th></tr>
								<tr><th align="left"><font color="#FFFFFF">Password</font></th><th><input type="password" name="pass" /></th></tr>
								</table>
								
								<center><input type="submit" value="  Login  "/></center>
								<br /><br />
							</form><br /><br /><br />
							
							<center><font size="3" color="#FFFFFF"><br /><b><u>Sign Up</u></b></font></center><br /><br />
							<font color="#FF0000"><b>*</b></font> indicates a required field.<br /><br />
					
							<form name="sign_up" method="POST" action="javascript: void(0);">
								<table border="0">
								<tr><th align="left"><font color="#FFFFFF"><font color="#FF0000">*</font>Username</font></th><th><input type="text" name="uname" /></th></tr>
								<tr><th align="left"><font color="#FFFFFF"><font color="#FF0000">*</font>Email</font></th><th><input type="text" name="email" /></th></tr>
								<tr><th align="left"><font color="#FFFFFF"><font color="#FF0000">*</font>Password</font></th><th><input type="password" name="pass" /></th></tr>
								<tr><th align="left"><font color="#FFFFFF"><font color="#FF0000">*</font>Confirm<br />&nbsp;&nbsp;&nbsp;Password</font></th><th><input type="password" name="pass2" /></th></tr>
								</table>
								
								<center><input type="submit" value="Sign Me Up" onclick="validateForm();"/></center>
								<br /><br />
							</form>
						</div>';
						
		if(isset($_COOKIE['session_id']) && isset($_COOKIE['user_id'])){
			$session = addslashes($_COOKIE['session_id']);
			$uid = addslashes($_COOKIE['user_id']);
			
			include('config.php');
			
			$query = 'SELECT u.username, count FROM USERS u JOIN (SELECT COUNT(*) "count" FROM USERS WHERE user_id=' . $uid . ' AND password=\'' . $session . '\') d WHERE user_id=' . $uid . ' AND password=\'' . $session . '\'';
						
			$results = mysql_query($query);
			$row = mysql_fetch_array($results);
			
			if($row['count'] >= 1){
				echo '<div id="email">';
				echo '<br /><br /><center><a style="text-decoration: none; color: #FFFFFF" href="index.php?page=profile&id=' . $uid . '"><b>' . $row['username'] . '</b></a></center>';
				echo '<br /><center><img src="images/osu.png" /></center><br />';
				echo '<center><a style="text-decoration: none; color: #FFFFFF" href="login.php"><b>Logout</b></a></center><br /><br />';
				echo '<div style="border-top: 1px solid #FFFFFF; padding-top: 25px;">';
				echo '<center><b>Useful Links</b></center><ul>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="http://developer.android.com/sdk/index.html"><b>Android SDK</b></a></li>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="http://www.eclipse.org/downloads/"><b>Eclipse</b></a></li>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="http://www.oracle.com/technetwork/java/javase/downloads/index.html"><b>Java JDK</b></a></li>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="http://docs.oracle.com/javase/6/docs/api/"><b>Java API</b></a></li>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="http://developer.android.com/guide/index.html"><b>Android Dev Guide</b></a></li>';
				echo '<li><a style="text-decoration: none; color: #FFFFFF" href="https://market.android.com/publish/Home"><b>Android Dev Console</b></a></li>';
				echo '</ul>';
				echo '</div>';
				echo '</div>';
			}else{
				echo $login_sidebar;
			}
			
			mysql_close($mysql_handle);
		}else{
			echo $login_sidebar;
		}
		
		if(isset($_GET['page'])){
			$page = addslashes($_GET['page']);
			
			if($page == 'threads'){
				if(isset($_GET['id'])){
					$id = addslashes($_GET['id']);
					
					include('thread.php');
				}
			}
			
			if($page == 'profile'){				
				if(isset($_GET['id'])){
					$id = addslashes($_GET['id']);
					
					include($page . '.php');
				}
			}
			
			if($page == 'active'){
				echo '<h2>Your account is now active.  You may now login and begin posting.</h2>';
			}
			
			if($page == 'users' || $page == 'viewthreads'){				
				include($page . '.php');
			}
			
		}else{
			echo '<div style="float: left;">
					<br /><font size="2"><b>Database Screenshots (Click to Enlarge)</b></font><br />
					<tr><td>
					<a href="images/project_images/comment_history.png"><img src="images/project_images/comment_history.png" width="100" height="75" /></a></td>
					<td><a href="images/project_images/post_count.png"><img src="images/project_images/post_count.png" width="100" height="75" /></a></td>
					<td><a href="images/project_images/thread_history.png"><img src="images/project_images/thread_history.png" width="100" height="75" /></a></td>
					<td><a href="images/project_images/thread_select.png"><img src="images/project_images/thread_select.png" width="100" height="75" /></a></td>
					<td><a href="images/project_images/users_select.png"><img src="images/project_images/users_select.png" width="100" height="75" /></a></td>
					
					<br /><br /><font size="6"><b>Getting Started With Android Dev</b></font><br /><br />

					<object width="640" height="350">
						<param name="movie" value="http://www.youtube.com/v/B1uaeKd4CXo?version=3&amp;hl=en_US"></param>
						<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
						<embed src="http://www.youtube.com/v/B1uaeKd4CXo?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="640" height="350" allowscriptaccess="always" allowfullscreen="true"></embed>
					</object><br />
				</div>';
				
			include('config.php');
			
			$query = 'SELECT * FROM THREADS ORDER BY last_post DESC LIMIT 0, 5';
			$results = mysql_query($query);
			
			echo '<div style="float: left; padding-top: 20px;">';
			echo '<h2>Latest Thread Activity</h2>';
			echo '<table border="4" id="generic">';
			echo '<tr><td><b>Topic</b></td> <td><b>Original Poster</b></td> <td><b>Last Post</b></td> <td><b>Post Count</b></td></tr>';
			
			while($row = mysql_fetch_array($results)) {
				echo '<tr><td><a href="index.php?page=threads&id=' . $row['thread_id'] . '">' . $row['topic'] . '</a></td><td>' . 
				$row['username'] . '</td><td>' . 
				$row['last_post'] . '</td><td>' . 
				$row['post_count'] . 	'</td></tr>';
			}	
			
			echo '</table>';
			echo '</div>';
			mysql_close($mysql_handle);
		}
				
		echo '</div>';
	?>
	
	<br />
	<br />
	<center><b><font size="2">Copyright &copy; 2012<br />Robert Phillips III &amp; Kyle Haley</font></b></center>
	
	<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js" ></script>
	<script type="text/javascript" src="scripts/functions.js" ></script>

</body>
</html>